#include <iostream>

#include "net_common.hpp"
#include "net_message.hpp"

enum class MsgTypes : uint32_t
{
    SEND,
    RECV
};

int main()
{
    dw::net::message<MsgTypes> msg(MsgTypes::SEND);
    std::string num = "0123456789";
    std::string str = "abcdefghijklmnopqrstuvwxyz";

    msg << num << str;
    std::cout << msg << std::endl;
    std::cout << "Message Constructed!" << std::endl;

    std::string out;
    
    msg >> out;
    std::cout << out << std::endl;
    std::cout << "Message str Parsed!" << std::endl;
    
    msg >> out;
    std::cout << out << std::endl;
    std::cout << "Message num Parsed!" << std::endl;

    std::cout << msg << std::endl;
    std::cout << "Message Popped!" << std::endl;

    msg << num + str;
    std::cout << msg << std::endl;
    std::cout << "Message Constructed!" << std::endl;

    msg.clear();
    std::cout << "Message Cleared!" << std::endl;

    msg.append(num);
    msg.append(str);
    std::cout << msg << std::endl;
    std::cout << "Message Constructed!" << std::endl;

    out = msg.data();
    std::cout << out << std::endl;
    std::cout << "Message data" << std::endl;

    std::cout << "Origin" << std::endl;
    std::cout << std::hex;
    std::cout << "Hex: " << msg.header << std::endl;
    std::cout << std::dec;
    std::cout << "Dec: " << msg.header << std::endl;

    std::cout << "NetOrder" << std::endl;
    msg.header = msg.header.NetOrder();
    std::cout << std::hex;
    std::cout << "Hex: " << msg.header << std::endl;
    std::cout << std::dec;
    std::cout << "Dec: " << msg.header << std::endl;

    std::cout << "HostOrder" << std::endl;
    msg.header = msg.header.HostOrder();
    std::cout << std::hex;
    std::cout << "Hex: " << msg.header << std::endl;
    std::cout << std::dec;
    std::cout << "Dec: " << msg.header << std::endl;

    return 0;
}